﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JavascriptDemos._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">
     function A(){   
    var answer1 = function(str){   
             alert("这里提供复杂功能1");   
    }   
    var answer2 = function(str){   
        alert("这里提供复杂功能2");   
    }   
    this.getAnswer = function(flag){   
        if(flag)   
                     return answer1;   
         else  
             return answer2;   
     }   
     this.answer = function(){   
         answer1();   
     }   
 }   
  
var control = new A();   
var a1 = control.getAnswer(true);   
 a1();   
 a1 = function(){alert("change");};   
 a1();
  control.answer();//弹出文字:这里提供复杂功能1    
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>
